L10 
W65 
UThe LOGO NotebookU 
 
by R.H. Mitchell 
 
Our last article covered LOGO variables, and finished with a short demo program that contained a beginning and an ending but not much in the middle. We're going to work on that as the 'Notebook' unfolds. We may not get to it every time, but if you type in the periodic updates, you'll end up with a bare-bones tutorial on the LOGO language which should be sufficient to refresh your memory from time to time. We're not quite ready yet to make the demo useful, but right now it's serving to illustrate some of the basic concepts that make up this very powerful graphics language. 
 
This time we'll be talking about colours, and we'll update the demo to make it into the beginnings of a menu for our tutorial. You still won't be able to do much with it except provide me with suggestions about where to take it from its present state. That would indeed be useful. 
 
Colours - LOGO Manual, Chapter 5. 
 
Last time you probably noted that there were some commands used in the demo that had not been discussed. There were things like SETBG, CHANGE.COLOR and FILL. These are three of the nine commands and operations that control LOGO screen colours. (By the way, do you remember the difference between a command and an operation?) 
 
In LOGO, you can independently control the colour of the screen background, the text colour, and the foreground colour just as you can in SmartBASIC. More easily than in BASIC, you can also control the sprite colour and the colour with which lines are drawn. We haven't introduced the infamous TURTLE yet, but the turtle is in fact a series of sprites. The turtle can draw a line wherever he goes, because he has a pen for that purpose. You can set the pen up or down, as you would in a BASIC drawing program and you can change the pen's colour. 
 
As with SmartBASIC, there are 16 colours in LOGO and the table is exactly the same. The colours are numbered 0 to 15 and listed on page 58 of LOGO's Reference Manual. The big difference between BASIC and LOGO is that with LOGO it's quite easy to put all 16 colours on the screen at once...if you wish to. Now that can also be done from BASIC, but it takes more programming. 
 
So..there's the turtle colour, the pen colour, the background colour and the text colour. Here are the commands. 
 
SETBG 
 
SETBG takes an input, a number between 0 and 15. So the syntax is:

   SETBG 10 
 
which would set the screen to dark yellow. With this command, you change the whole screen to the selected colour. 
 
BACKGROUND (short form BG) 
 
BG is an operation. That is, it must be used in conjunction with a command, or another procedure because all it does is to output the current background value. If you were to type simply: 
 
BG 
 
you'd get an error message saying.. 
 
YOU DON'T SAY WHAT TO DO WITH 10 
 
Remember, something must be done with the output of an operation. In this case, it must be printed. So the correct syntax is: 
 
PR BG 
 
and LOGO would respond 
 
10 
 
COLOR 
 
Likewise, COLOR is also an operation. You type: 
 
PR COLOR 
 
and LOGO responds with 
 
15 
 
which is the default value for the present turtle color. 
 
SETCOLOR 
 
You can change that with the command SETCOLOR or SETC (short form). SETCOLOR takes an input, like SETBG, a number between 0 and 15 depending on which colour you want. 
 
PENCOLOR (PC) 
SETPC 
 
The first of these two is an operation and will output the current turtle pen colour. If the pen is down, wherever the turtle goes, he'll draw a line behind him. The colour of the line depends on the PC value. SETPC is the command used to change the pen colour. 
 
CHANGE.COLOR 
 
This one is also a command. It affects both graphics and text and will change the colour of letters and lines currently on the screen from something to something else. Hence the syntax: 
 
CHANGE.COLOR 15 1 
 
which would change from white to black print, and white to black turtle pen colour. It does not affect the background colour or the turtle colour. 
 
With this arsenal of commands and operations, there no limit to what you can easily do with screen colours. We're going to amend our demo shortly to give you some idea of what can be done. 
 
Before we do that however, we need to do a little housecleaning which requires us to learn something more about the LOGO workspace. 
 
By workspace, we're talking about the ADAM memory you have at your disposal. When you create a LOGO procedure, it goes into the workspace and can be called by name whenever it's required either directly from the keyboard or from another procedure. It stays in the workspace until it is erased or until ADAM is reset or turned off. When you're saving a file to tape or disk, as we did last time, you in fact save everything in your workspace at that time. If you typed in the demo, you'll have a file on your media called DEMO.LGO. 
 
Get that back now by typing: 
 
LOAD "DEMO.LGO 
 
(don't forget the quotes, they're essential....can you remember why?) 
 
Now. In DEMO.LGO there were a number of procedures. Couldn't for the life of me remember what they were, so having read ahead a little, I typed: 
 
POTS 
 
Print out titles. 
 
LOGO responded with: 
 
TO TITLE 
TO START 
TO PROGRAM 
TO FINISH 
TO SQUARE :COLOR 
TO DRAWSQUARES 
TO PRTVRBLS 
 
and that was our demo. 
 
To carry on from there, we'll make some changes. Type 
 
ER PRTVRBLS 
 
That will remove the procedure PRTVRBLS from the workspace leaving all the others intact. If you wanted to clear the workspace completely, you would type ERALL. Don't do that, just yet. 
 
Remember that the procedure PRTVRBLS was also contained somewhere else.... in the mainline procedure called PROGRAM. So you'll have to edit PROGRAM to remove it, since LOGO no longer knows how to PRTVRBLS. 
 
type.. 
 
TO PROGRAM 
 
LOGO places you in the edit mode and lists out the procedure PROGRAM. Move your cursor down to the line PRTVRBLS and use the delete key to remove it. Then press Smarkey VI. PROGRAM is redifined. 
 
There are some other changes made to the demo. A revised listing follows, and you'll need to compare your version with the new one, editing in the appropriate amendments to the different procedures as described for the change to PROGRAM. 
 
You'll note the use of the FILL command, and that we've not talked about it. We'll do that next time, because it's now become essential to introduce our friend the TURTLE. Can't do much more without him, and he's what makes LOGO special. 
 all the others
